/*
 * @Author: yt 2399493770@qq.com
 * @Date: 2024-04-17 16:56:39
 * @LastEditors: yt 2399493770@qq.com
 * @LastEditTime: 2024-04-26 00:48:49
 * @Description:
 */

import { Router } from "express";
import { dataDecryptByAES, useSign } from "../../../hooks/useSign";
import { BasicsResult } from "../../../helpers/BasicsResult";
import { useGetALLTask, useGetRedisValue } from "../../../hooks/useRedis";
import { getCarIllegalQuery } from "../../../api";
import { useSetTask } from "../../../hooks/useTask";
import { carIllegal, carIllegalBatch } from "../verify";
import { apiHandler } from "../../../helpers/basicsAuth";

const taskRouter = Router();

interface CarIllegalBatchBody {
  carList: Array<any>;
  id: string;
}


const carIllegalBatchQuery = apiHandler(
  (_, params) => {
    return new Promise((resolve, reject) => {
      try {
        const { carList }: CarIllegalBatchBody = params;
        carList.forEach((item) => {
          useSetTask(item.id, item);
        });
        resolve(null);
      } catch (error) {
        reject(error);
      }
    });
  },
  { schema: carIllegalBatch, isJwt: false }
);

taskRouter.post("/car_illegal_batch_query", async (req, res) => {
  carIllegalBatchQuery(req, res, req.body);
});

export default taskRouter;
